from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import get_game
from items.Binoculars import Binoculars

class river1(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
           
        # build list of actions
        self.add_action(Out)
        self.add_action(Down)
        self.add_action(Swim)
        self.add_item(Binoculars())
    
    # return description of room.
    def get_description(self):
        return "You hike along the river trail, coming across some calm pools, who knows what is lurking beneath the surface."
    
    # return image of room
    def get_image(self):
        return 'river1.jpg'
    
        # Are boots on
    def is_booted(self):
        
        game = get_game()
        
        # are boots on?
        if 'Boots' in self.inventory:
            if self.inventory['Boots'].is_booted:
                return True
     
        player = game.get_player()
        if 'Boots' in player.inventory:
            if player.inventory['Boots'].is_booted:
                return True
                
        # if not, return this
        return False

class River1Handler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return river1

# define actions for this room

class Out(Action):
    def __init__(self):
        Action.__init__(self, "Out")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Walk toward the Lodge"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'outside'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"


class Down(Action):
    def __init__(self):
        Action.__init__(self, "Down")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Continue along the river path"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'river2'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    
class Swim(Action):
    def __init__(self):
        Action.__init__(self, "Swim")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Swim across the river"
    
    def get_destination(self):
        if self.room.is_booted():
            return 'death'
        else:
            return 'river3'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

    